﻿

namespace Risk.Model
{
    public class Troop : UniqueId
    {
        public int TroopSize { get; private set; }
        public Region Region { get; private set; }
        public Troop(int size, Region region)
        {
            TroopSize = size;
            Region = region;
        }

        public Troop(int id, int size, Region region)
            : this(size, region)
        {
            Id = id;
            Region = region;
        }
        public int Defenders { get { return TroopSize > 2 ? 2 : TroopSize; } }

        public void AddTroop()
        {
            TroopSize += 1;
        }

        public void AddTroopsFromReserve(int reserve)
        {
            TroopSize += reserve;
        }

        public bool CanAttackWith(int numberOfDice)
        {
            return TroopSize > numberOfDice;
        }

        public void RemoveTroops(int nrDead)
        {
            TroopSize -= nrDead;
        }

        public bool CanMove(int numberOfTroops)
        {
            return TroopSize > numberOfTroops;
        }

        public void MoveTroops(Troop toTroop, int number)
        {
            toTroop.TroopSize += number;
            TroopSize -= number;
        }
    }
}
